package com.ciaojian.core.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ciaojian.core.model.OrderCommission;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;

/**
 * @author oxiny
 */
public interface OrderCommissionMapper extends BaseMapper<OrderCommission> {

    /**
     * 计算业绩排名
     *
     * @param storeId 门店ID
     * @param date    日期
     * @param page    分页插件
     * @return 发型师业绩
     */
    @MapKey("worker_id")
    Page<Map<String, Object>> calculateRank(Page<Map<String, Object>> page,
                                            @Param("storeId") Integer storeId,
                                            @Param("date") Date date);

    /**
     * 统计业绩
     *
     * @param workerId  发型师ID
     * @param types      类型
     * @param beginDate 开始时间
     * @param endDate   结束时间
     * @return /
     */
    Integer sumAmount(@Param("workerId") Integer workerId,
                      @Param("types") Integer[] types,
                      @Param("beginDate") Date beginDate,
                      @Param("endDate") Date endDate);

    BigDecimal getWorkerCommiss(@Param("workerId") Integer workerId, @Param("beginDate") Date beginDate, @Param("endDate") Date endDate);

    BigDecimal dyPerformanceDouble(@Param("workerId") Integer workerId, @Param("beginDate") Date beginDate, @Param("endDate") Date endDate);


    Integer getMemberNum(@Param("workerId") Integer workerId, @Param("beginDate") Date beginDate, @Param("endDate") Date endDate);
}
